package com.oocl.euc.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

import com.mongodb.Mongo;
import com.oocl.euc.entity.Dish;
@Repository("dishDao") 
public class DishDaoImpl extends CommonRepository<Dish>{
	@Autowired
	private MerchantDaoImpl md;
//	private static org.apache.log4j.Logger logger = Logger.getLogger(DishDaoImpl.class);
//	private static Logger log4j2=LogManager.getLogger(DishDaoImpl.class);

	public List<Dish> findDishesByMid(String mid) {
		Criteria criteria=new Criteria("merchant").is(md.findById(mid));
		return find(criteria);
	}


	public Integer updateDish(Dish d) {
		Update update=new Update();
		update.set("dname", d.getDname());
		update.set("price", d.getPrice());
		return findAndModify(Criteria.where("did").is(d.getDid()), update);
	}
}
